package com.icw.configuration.lifecycle;

import static com.icw.configuration.ConstSettings.INITIAL_PACKAGE;

import java.util.Set;

import com.icw.basis.ModuleInitialization;
import com.icw.utility.ClassUtil;

public class AfterAppLaunch {

	private static boolean runned = false;

	protected void after() throws Exception {
		if (!runned && (runned = true)) run();
	}

	private void run() throws Exception {
		Set<Class<?>> initials = ClassUtil.getClasses(INITIAL_PACKAGE);
		for (Class<?> c : initials) {
			ModuleInitialization instance = (ModuleInitialization) c.getConstructor().newInstance();
			instance.initialize();
		}
	}
}
